package net.minecraft.src;

import java.util.Random;

public class TexturePPHPortalFX extends TextureFX
{

	public TexturePPHPortalFX()
	{
		super(mod_pph.portalBlock.blockIndexInTexture);
		brightness = new float[256];
        alpha = new boolean[256];
	}

	public void onTick()
    {
		Random random = new Random(100L);
		for (int j = 0; j < 16; j++)
		{
			for (int k = 0; k < 16; k++)
			{
				float effect = 0.0F;
				for (int l = 0; l < 2; l++)
				{
					float f1 = l * 8;
					float f2 = l * 8;
					float f3 = (((float) j - f1) / 16F) * 2.0F;
					float f4 = (((float) k - f2) / 16F) * 2.0F;
					if (f3 < -1F)
					{
						f3 += 2.0F;
					}
					if (f3 >= 1.0F)
					{
						f3 -= 2.0F;
					}
					if (f4 < -1F)
					{
						f4 += 2.0F;
					}
					if (f4 >= 1.0F)
					{
						f4 -= 2.0F;
					}
					float f5 = f3 * f3 + f4 * f4;
					float f6 = (float) Math.atan2(f4, f3) + ((((float) (tickCounter & 0x1F) / 32F) * 3.141593F * 2.0F - f5 * 10F) + (float) (l * 2)) * (float) (l * 2 - 1);
					f6 = (MathHelper.sin(f6) + 1.0F) / 2.0F;
					f6 /= f5 + 1.0F;
					effect += f6 * 0.5F;
				}

				effect += random.nextFloat() * 0.2F;
				int alpha = (int) (effect * 205F + 50F);
				int red = (int) (effect * 100F);
				int green = (int) (effect * 255F);
				int blue = (int) (effect * 30F);
				int slot = (j * 16) + k;
				imageData[slot * 4 + 0] = (byte) red;
				imageData[slot * 4 + 1] = (byte) green;
				imageData[slot * 4 + 2] = (byte) blue;
				imageData[slot * 4 + 3] = (byte) alpha;
			}

		}
       
        tickCounter++;
    }
	
	protected float[] brightness;
	protected boolean[] alpha;
	private int tickCounter;
}